var content = '<ul>'
    {{range $dir, $files := .ArchDirs}}
    + '<li>'
    + '<h2>{{$dir}}</h2>'
    + '<ul>'
        {{range $idx := $files}}
        + '<li>{{getArchiveString $idx}}</li>'
        {{end}}
    + '</ul>'
    + '</li>'
    {{end}}
    + '</ul>';

var getAbsoluteUrl = (function() {
    var a;
    return function(url) {
        if(!a) a = document.createElement('a');
        a.href = url;
        return a.href;
    };
})();

var loadSidebar = function(urlpre) {
    urlpre = urlpre || '';
    var node = document.getElementById('sidebar');
    node.outerHTML = content.replace(/@URLPRE@/gm, urlpre);
};